package star.cloud.asme.system.role.menu;

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import star.cloud.asme.base.dto.Result;
import star.cloud.asme.base.mybatis.IBaseController;

import java.util.List;

@RestController
@RequestMapping("/system/role/menu")
@RequiredArgsConstructor
public class MenuController implements IBaseController<Menu> {

    private final MenuService menuService;

    @Override
    public Result<Menu> insertOne(Menu entity) {
        return menuService.insertOne(entity);
    }

    @Override
    public Result<?> physicalDeleteById(Long id) {
        return menuService.physicalDeleteById(id);
    }

    @Override
    public Result<?> logicalDeleteById(Long id) {
        return menuService.logicalDeleteById(id);
    }

    @Override
    public Result<Menu> updateOne(Menu entity) {
        return menuService.updateOne(entity);
    }

    @Override
    public Result<List<Menu>> getListByConditions(Menu entity) {
        return menuService.getListByConditions(entity);
    }

    @PutMapping("/resetMenusByRoleId")
    public Result<?> resetMenusByRoleId(MenuDTO menuDTO) {
        return menuService.resetMenusByRoleId(menuDTO);
    }

    @GetMapping("/userId/{userId}")
    public Result<List<String>> getMenuListByUserid(@PathVariable("userId") Long userId) {
        return menuService.getMenuTitleListByUserId(userId);
    }

}